import { ajaxService } from '@/utils/request';
import * as Type from './type';
const env = import.meta.env;
// const baseURL = 'http://192.168.31.113:9081';
// const baseURL = 'http://192.168.0.240:9081';
const baseURL = env.VITE_APP_BASE_URL;
const baseURL1 = env.VITE_DEV_BASE_URL; // const baseURL1 = env.VITE_APP_BASE_URL;
const baseURL2 = env.VITE_APP_BASE_URL;
/**
 * 获取控件总集
 * @returns
 */
export function GetBusinessModalData(params: Type.params) {
  return ajaxService<Type.Data>({
    url: '/platform_management/platform_ccc/open_api/cccApi/func/ctl',
    method: 'get',
    params,
    baseURL
  });
}

// 获取数据来源内容数据
export function getDataResourcesValue(data: {
  url: string;
  method: 'post' | 'get';
  params?: any;
  differentPorts?: number;
}) {
  return ajaxService<any>({
    url: data.url,
    method: data.method,
    params: data.params,
    // data:data.params,
    baseURL: data.params.differentPorts === 2 ? baseURL2 : baseURL1
  });
}
/**
 * 数据来源详情
 * @param id
 * @returns
 */
export async function getDataResourcesById(id: number) {
  return ajaxService<any>({
    url: `/platform_management/platform_ccc/open_api/dr/data/resources/${id}`,
    method: 'get',
    baseURL
  });
}
